<?php 
class subjects_Form_FrmSubject extends Zend_Form
{
	public function frmSubject($frm = null)
    {
    	$dbBranch = new faculty_Model_DbTable_DbFaculty();
    	$rsBranch =$dbBranch->getAllBranch();
    	$optBranch = array(''=>'ជ្រើសរើស សាខា/Choose Branch');
    	foreach ($rsBranch as $dataBranch){
    		$optBranch[$dataBranch["branch_id"]] = $dataBranch["branch_name"];
    	}
    	$branch = new Zend_Form_Element_Select('branch');
    	$branch->setAttribs(array('class'=>'form-control chzn-select validate[required]','OnChange'=>'getDepartment();'));
    	$branch->setMultiOptions($optBranch);
    	
    	$dbDpt = new department_Model_DbTable_DbDepartment();
    	$dpts = $dbDpt->getDepartments();
    	$optDpt = array();
    	foreach ($dpts as $dpt){
    		$optDpt[$dpt["department_id"]] = $dpt["department_name"];
    	}
    	$department = new Zend_Form_Element_Select("department");
    	$department->setAttribs(array('class'=>'form-control','id'=>"box1View", 'multiple'=>"multiple", 'size'=>"8"));
    	$department->setMultiOptions($optDpt);
    	
    	$department_selected = new Zend_Form_Element_Select("department_selected");
    	$department_selected->setAttribs(array('class'=>'form-control validate[required]','id'=>"box2View", 'multiple'=>"multiple", 'size'=>"8"));
    	
    	$subject = new Zend_Form_Element_Text("subject");
    	$subject->setAttribs(array('class'=>'form-control validate[required]'));
    	
    	$status = new Zend_Form_Element_Select('status');
    	$status->setAttribs(array('class'=>'form-control validate[required]'));
    	$opt_status = array(''=>'ជ្រើសរើស ស្ថានភាព','1'=>'ប្រើប្រាស់','0'=>'មិនប្រើប្រាស់');
    	$status->setMultiOptions($opt_status);
    	
    	$description = new Zend_Form_Element_Textarea("description");
    	$description->setAttribs(array('class'=>'form-control'));
    	
    	$id = new Zend_Form_Element_Hidden('id');
    	$this->addElements(array($subject,$department,$branch,$status,$description,$id));    	
    	if($frm){
    		$id->setValue($frm['department_id']);
    		$department->setValue($frm["department_name"]);
    		$status->setValue($frm["status"]);
    		$description->setValue($frm["description"]);
    		$faculty->setValue($frm["faculty_id"]);
    		$branch->setValue($frm["branch_id"]);
    	}
    	return $this;
     }
}
?>
